@RequestParam Annotation
● is used to read HTTP Request Parameters
● is assigned to end-point Input Parameter - to Input Parameter of a @RequestMapping Method inside Controller
● stores HTTP Request Parameter that has the same as that Input Parameter (into that Input Parameter)
MyController.java
@ResponseBody
@RequestMapping("/Hello")
public String sayHello(@RequestParam String name) {
return "Hello " + name;
}
Application Schema [Results]
Spring Boot Starters
Create Project: springboot_httprequest_requestparam (add Spring Boot Starters from the table)
Create Package: controllers (inside main package)
– Create Class: MyController.java (inside package controllers)
MyController.java
package com.ivoronline.springboot_httprequest_requestparam.controllers;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class MyController {
@ResponseBody
@RequestMapping("/Hello")
public String hello(@RequestParam String name) {
return "Hello " + name;
}
}